﻿namespace HabraReader
{
    using System;
    using System.Globalization;
    using System.Collections.Specialized;
    using System.Windows.Forms;
    using System.IO;
    using Classes;

    public partial class InfoForm : Form
    {
        private readonly MainForm MainWindow;
        private StringDictionary  OptionsDictionary;

        public InfoForm(MainForm mainform)
        {
            MainWindow = mainform;
            this.InitializeComponent();
        }

        private void CloseClick(object sender, EventArgs e)
        {
            this.Close();
        }

        private void InfoFormLoad(object sender, EventArgs e)
        {
            OptionsDictionary = MainWindow.OptionsDictionary;
            Database.Text     = OptionsDictionary["Database"];
            var fileInfo      = new FileInfo(OptionsDictionary["Database"]);
            long size         = fileInfo.Length;
            double sizeMb     = size / 1024.0 / 1024.0;
            Size.Text         = size + " байт (" +  sizeMb.ToString("F", CultureInfo.InvariantCulture) + " мб)";
            var db            = new Database(OptionsDictionary["Database"]);

            Blogs.Text    = db.GetBlogsCount().ToString();
            Articles.Text = db.GetAllArticlesCount().ToString();
        }
    }
}